package com.sinsoft.monitorDemo.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sinosoft.framework.core.common.utils.ajax.ResponseData;
import com.sinsoft.monitorDemo.dao.NetInfoDao;
import com.sinsoft.monitorDemo.entity.NetInfo;

@Controller
@RequestMapping("/NetInfo")
public class NetInfoController {
	
	/**
	 * 得到一段时间的的的网络状态信息
	 * @return
	 */
	@RequestMapping(value = "/getNetInfoList", method = RequestMethod.POST)
	@ResponseBody
	public ResponseData getNetInfoList(HttpServletRequest request){
		NetInfoDao dao = new NetInfoDao();
		String ip = request.getParameter("ip");
		List<NetInfo> netInfos = dao.getNetInfoList(ip);
		ResponseData responseData = new ResponseData(true, netInfos);
		return responseData;	
	}
	
	/**
	 * 得到最新的网络状态信息
	 * @return
	 */
	@RequestMapping(value = "/getNewNetInfo", method = RequestMethod.POST)
	@ResponseBody
	public ResponseData getNewCpuinfo(HttpServletRequest request){
		NetInfoDao dao = new NetInfoDao();
		String ip = request.getParameter("ip");
		NetInfo netInfo = dao.getNewNetInfo(ip);
		ResponseData responseData = new ResponseData(true, netInfo);
		return responseData;	
	}
}
